POV-Ray : Newsgroups : povray.advanced-users : REQ: reorienting a vector : Re: REQ: reorienting a vector Server Time
30 Jul 2024 14:23:26 EDT (-0400)
  Re: REQ: reorienting a vector  
From: Ronald L  Parker
Date: 24 Apr 1999 23:21:19
Message: <372379f4.216088045@news.povray.org>
On Sun, 25 Apr 1999 05:01:07 +0300, "Margus Ramst"
<mar### [at] peakeduee> wrote:

>Ronald L. Parker wrote in message <372271a9.213964711@news.povray.org>...
>>
>>John VanSickle's Thoroughly Useful Macros will help with this.  A copy
>>of the one you need can be found at http://twysted.net/macroscope
>>
>
>I don't think so. The Reorient macro is close, but it uses matrix
>transformation to reorient an object. What I need is a rotation vector I
>could use in vrotate().

Ah, okay, that's actually how I read it at first, but I couldn't
imagine why you would need such a thing so then I assumed that you
really wanted the Reorient macro.  I can get you an angle and an axis,
which you can use with vaxis_rotate(), if you'd like.  This isn't
tested, so it may be faulty.  In particular, you may have to fix the
sign on the angle. (It's times like this that I don't trust a
left-handed coordinate system.)  You may, of course, get rid of all
the intermediate local variables and make this a one-liner.

#macro vvec_rotate( Vec, RefA, RefB )
  #local nA = vnormalize(RefA);
  #local nB = vnormalize(RefB);
  #local axis = vcross(nA,nB);
  #local angle = degrees(atan2(vlength(axis),vdot(nA,nB)));
  vaxis_rotate( Vec, axis, angle );
#end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.